﻿<%@ Page Language="C#" MasterPageFile="~/Hoso/MasterPage_Hoso.master" AutoEventWireup="true" CodeFile="QuanlyThanhvien.aspx.cs" Inherits="Hoso_QuanlyThanhvien" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register TagPrefix="uc" TagName="Menu" Src="~/Hoso/QuantriMenu.ascx"%>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <uc:Menu ID="menu" runat="server" /> 
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">

     <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
      <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
        
         <!-- load ajax-->
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <!-- end-->
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>  
    <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
    
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" 
         AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
          AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"
           ondatabound="RadGrid1_DataBound" onitemdeleted="RadGrid1_ItemDeleted" 
        oniteminserted="RadGrid1_ItemInserted" 
        onitemupdated="RadGrid1_ItemUpdated" Skin="Office2007" 
        onitemcommand="RadGrid1_ItemCommand" PageSize="5" 
         >


<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="mathanhvien" CommandItemDisplay="Top">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
      
     <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColum" FilterControlAltText="Filter EditCommandColumn column">
                    </telerik:GridEditCommandColumn>
        <telerik:GridBoundColumn DataField="mathanhvien" DataType="System.Int32" 
            FilterControlAltText="Filter mathanhvien column" HeaderText="Mã thành viên" 
            ReadOnly="True" SortExpression="mathanhvien" UniqueName="mathanhvien">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="tenthanhvien" 
            FilterControlAltText="Filter tenthanhvien column" HeaderText="Tên thành viên" 
            SortExpression="tenthanhvien" UniqueName="tenthanhvien">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="chucvu" 
            FilterControlAltText="Filter chucvu column" HeaderText="Chức vụ" 
            SortExpression="chucvu" UniqueName="chucvu">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="email" 
            FilterControlAltText="Filter email column" HeaderText="Email" 
            SortExpression="email" UniqueName="email">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="hinh" 
            FilterControlAltText="Filter hinh column" HeaderText="Hình" 
            SortExpression="hinh" UniqueName="hinh">
        </telerik:GridBoundColumn>
        <telerik:GridButtonColumn ConfirmText="Delete this thành viên?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridButtonColumn>
    </Columns>

<EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="mathanhvien" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Thanhvien">
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
<FormTemplate>    
<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;">
                        <tr class="EditFormHeader">
                            <td colspan="2" style="font-size: small">
                                <b>Thêm thành viên</b>
                            </td>
                        </tr>   
        <tr>
            <td style="width: 562px">
                Tên thành viên</td>
            <td style="width: 250px">
                <asp:TextBox ID="txttenthanhvien" runat="server" Text='<%# Bind("tenthanhvien") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="nhập tên" ControlToValidate="txttenthanhvien"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 562px">
                Chức vụ</td>
            <td style="width: 250px">
                <asp:TextBox ID="txtchucvu" runat="server" Text='<%# Bind("chucvu") %>'></asp:TextBox>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="nhập chức vụ" ControlToValidate="txtchucvu"></asp:RequiredFieldValidator>
            </td>
        </tr>
         <tr>
            <td style="width: 562px">
                Email</td>
            <td style="width: 250px">
                <asp:TextBox ID="txtemail" runat="server" Text='<%# Bind("email") %>'></asp:TextBox>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
        ControlToValidate="txtemail" ErrorMessage="Sai dạng Email" 
        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </td>
        </tr>
         <tr>
            <td style="width: 562px">
                Hình</td>
            <td style="width: 250px">
                <asp:TextBox ID="txthinh" runat="server" Text='<%# Bind("hinh") %>'></asp:TextBox>
            </td>
        </tr>
        <tr>
         <td align="right" colspan="2">
                                 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                  
                                 
                            </td>
        </tr>
        </table>
        </FormTemplate>
</EditFormSettings >
</MasterTableView>
 <ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="True" />
               <ClientEvents OnRowDblClick="RowDblClick" />
           </ClientSettings>
<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>


     <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
         SelectCommand="SELECT * FROM [THANHVIEN]" 
         ConflictDetection="CompareAllValues" 
         DeleteCommand="DELETE FROM [THANHVIEN] WHERE [mathanhvien] = @original_mathanhvien" 
         InsertCommand="sp_thanhvien_taikhoan" 
         OldValuesParameterFormatString="original_{0}" 
         
         UpdateCommand="UPDATE [THANHVIEN] SET [tenthanhvien] = @tenthanhvien, [chucvu] = @chucvu, [email] = @email, [hinh] = @hinh WHERE [mathanhvien] = @original_mathanhvien AND [tenthanhvien] = @original_tenthanhvien AND (([chucvu] = @original_chucvu) OR ([chucvu] IS NULL AND @original_chucvu IS NULL)) AND [email] = @original_email AND (([hinh] = @original_hinh) OR ([hinh] IS NULL AND @original_hinh IS NULL))" 
         InsertCommandType="StoredProcedure">
         <DeleteParameters>
             <asp:Parameter Name="original_mathanhvien" Type="Int32" />
            
         </DeleteParameters>
         <UpdateParameters>
             <asp:Parameter Name="tenthanhvien" Type="String" />
             <asp:Parameter Name="chucvu" Type="String" />
             <asp:Parameter Name="email" Type="String" />
             <asp:Parameter Name="hinh" Type="String" />
             <asp:Parameter Name="original_mathanhvien" Type="Int32" />
             <asp:Parameter Name="original_tenthanhvien" Type="String" />
             <asp:Parameter Name="original_chucvu" Type="String" />
             <asp:Parameter Name="original_email" Type="String" />
             <asp:Parameter Name="original_hinh" Type="String" />
         </UpdateParameters>
         <InsertParameters>
             <asp:Parameter Name="tenthanhvien" Type="String" />
             <asp:Parameter Name="chucvu" Type="String" />
             <asp:Parameter Name="email" Type="String" />
             <asp:Parameter Name="hinh" Type="String" />
         </InsertParameters>
     </asp:SqlDataSource>


</asp:Content>
